import 'package:flutter/material.dart';
import 'package:yp/config/config.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 选择切换按钮  多个页面都用到 所以独立出来
class SelectButton extends StatelessWidget {
  final String title;
  final bool isSelected;
  final double width;
  final Function onTap;

  const SelectButton({
    Key key,
    @required this.title,
    this.isSelected = false,
    this.width,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: width ?? 140.w,
        height: 50.w,
        decoration: BoxDecoration(
          color: isSelected ? Config.mainColor : Colors.white,
          borderRadius: BorderRadius.all(
            Radius.circular(100.w),
          ),
          border: isSelected
              ? Border.all(color: Config.mainColor)
              : Border.all(color: Color(0xfff0f0f0)),
        ),
        child: Center(
          child: Text(
            title,
            style: TextStyle(
              fontSize: 24.sp,
              color: isSelected ? Colors.white : Color(0xff222222),
            ),
          ),
        ),
      ),
    );
  }
}
